<?php

/**
 * AcctGeneralLedger form base class.
 *
 * @method AcctGeneralLedger getObject() Returns the current form's model object
 *
 * @package    tinystockmis
 * @subpackage form
 * @author     Linfeng Wu
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 24171 2009-11-19 16:37:50Z Kris.Wallsmith $
 */
abstract class BaseAcctGeneralLedgerForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                   => new sfWidgetFormInputHidden(),
      'acct_subject_id'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('AcctSubject'), 'add_empty' => false)),
      'acct_year'            => new sfWidgetFormInputText(),
      'acct_mon'             => new sfWidgetFormInputText(),
      'debit_amount'         => new sfWidgetFormInputText(),
      'credit_amount'        => new sfWidgetFormInputText(),
      'balance'              => new sfWidgetFormInputText(),
      'balance_debit_credit' => new sfWidgetFormChoice(array('choices' => array('d' => 'd', 'c' => 'c'))),
      'acct_set_id'          => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('AcctSet'), 'add_empty' => false)),
      'created_at'           => new sfWidgetFormDateTime(),
      'updated_at'           => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'                   => new sfValidatorDoctrineChoice(array('model' => $this->getModelName(), 'column' => 'id', 'required' => false)),
      'acct_subject_id'      => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('AcctSubject'))),
      'acct_year'            => new sfValidatorInteger(array('required' => false)),
      'acct_mon'             => new sfValidatorInteger(array('required' => false)),
      'debit_amount'         => new sfValidatorNumber(array('required' => false)),
      'credit_amount'        => new sfValidatorNumber(array('required' => false)),
      'balance'              => new sfValidatorNumber(),
      'balance_debit_credit' => new sfValidatorChoice(array('choices' => array(0 => 'd', 1 => 'c'))),
      'acct_set_id'          => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('AcctSet'))),
      'created_at'           => new sfValidatorDateTime(),
      'updated_at'           => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('acct_general_ledger[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'AcctGeneralLedger';
  }

}
